﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using System.Data;
using JM.JCY.Common;

namespace JM.JCY.SharePointComponent.QuickLink.QuickLinkHome
{
    public partial class QuickLinkHomeUserControl : UserControl
    {
        string listName = JCYConstant.SharePointListName.QuickLinkList;
        protected void Page_Load(object sender, EventArgs e)
        {
          
            if (!IsPostBack)
            {
                SPWeb web = SPContext.Current.Web;
                SPList docList = web.Lists[listName];
                this.lvQuickLink.ListId = docList.ID.ToString();
                lvQuickLink.ViewId = docList.Views["HomeView"].ID.ToString();
                string onclick = string.Format("javascript:NewItem2(event, '{0}');javascript:return false;", docList.DefaultNewFormUrl);
                this.idHomePageNewItemQuickLink.Attributes.Add("onclick", onclick);

                if (CommonFunction.IsApplicationAdmin(17))
                    this.idHomePageNewItemQuickLink.Visible = true;
                else
                    this.idHomePageNewItemQuickLink.Visible = false;

            }


        }

       
        protected void lbViewAllLink_Click(object sender, EventArgs e)
        {
              Response.Redirect(SPContext.Current.Site.ServerRelativeUrl + "LinkPages/ViewAllLinks.aspx");
        }
    }
}
